<template>
	<view class="PT_4">
		
		
		<view class="PTB_2 PLR_10">
			
			<view class="P_2 line_bom B_radius_5 flex_row_between">
				<view class="flex_rowL">
					<image class="W_4vw" src="../../static/mobile.png" mode="widthFix"></image>
					<input class="PL_2 W_30vw" v-model="mobile" type="text" placeholder="请输入手机号" />
				</view>
				<view class="P_2 B_radius_5 flex_rowL">
					
					<view v-if="hasCode" class="fontS_12 B_radius_5 pub_bg color_fff " style="padding: 0.8vw 2vw;">
					  {{ num + "秒后再试" }}
					</view>
					<view v-else @click="getVerify" class="fontS_10 pub_bg color_fff B_radius_5" style="padding: 0.8vw 2vw;">验证码</view>
				</view>
			</view>
			
			<view class="fontS_10 PT_4 PB_2 flex_rowL P_2 line_bom">
				<image class="W_4vw" src="../../static/dun.png" mode="widthFix"></image>
				<input class="PL_2" v-model="code" type="text" placeholder="请输入验证码" />
			</view>
			
			<view class="P_2 line_bom B_radius_5 PT_4 flex_rowL">
				<image class="W_4vw" src="../../static/pass.png" mode="widthFix"></image>
				<input class="PL_2" v-model="pass1" type="text" placeholder="请输入密码" />
			</view>
			
			<view class="P_2 line_bom B_radius_5 PT_4 flex_rowL">
				<image class="W_4vw" src="../../static/pass.png" mode="widthFix"></image>
				<input class="PL_2" v-model="pass2" type="text" placeholder="请确认密码" />
			</view>
			
			<view class="P_2 line_bom B_radius_5 PT_4 flex_rowL">
				<image class="W_4vw" src="../../static/pass.png" mode="widthFix"></image>
				<input class="PL_2" v-model="safe1" type="text" placeholder="请输入安全密码" />
			</view>
			<view class="P_2 line_bom B_radius_5 PT_4 flex_rowL">
				<image class="W_4vw" src="../../static/pass.png" mode="widthFix"></image>
				<input class="PL_2" v-model="safe2" type="text" placeholder="请确认安全密码" />
			</view>
			
			<view class="P_2 line_bom B_radius_5 PT_4 flex_rowL">
				<image class="W_4vw" src="../../static/pass.png" mode="widthFix"></image>
				<input class="PL_2" v-model="pcode" type="text" placeholder="请输入邀请码" />
			</view>
			
			<!-- <view class="P_2 B_1_gray B_radius_5">
				<input v-model="pcode" type="text" placeholder="请输入推荐码" />
			</view>
			<view class="fontS_10 PT_4 PB_2">
				登录密码
			</view>
			<view class="P_2 B_1_gray B_radius_5">
				<input v-model="pass1" type="text" placeholder="请输入登录密码" />
			</view>
			<view class="fontS_10 PT_4 PB_2">
				支付密码
			</view>
			<view class="P_2 B_1_gray B_radius_5">
				<input v-model="pass2" type="text" placeholder="请输入支付密码" />
			</view> -->
			
			<view @click="submit" class="pub_btn B_radius_max MT_6 PTB_2">
				确定
			</view>
			
			<!-- <view class="flex_row_between pub_color fontS_10 PT_4">
				<view class="">
					注册
				</view>
				<view class="">
					忘记密码
				</view>
			</view> -->
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hasCode:false,
				num:59,
				mobile:'',
				pass1:'',
				pass2:'',
				safe1:'',
				safe2:'',
				code:'',
				pcode:'',
			}
		},
		methods: {
			getVerify() {
			  //获取验证码
			  let _this = this;
			  if (!this.mobile) {
				this.toast('请先输入手机号')
			  } else {
			    this.$req('sms',{ phone: _this.mobile },(res) => {
			      if (res.code == 200) {
			        _this.hasCode = true;
			        _this.toast("验证码发送成功");
			        setInterval(() => {
			          if (_this.num > 0) {
			            _this.num--;
			          } else {
			            _this.hasCode = false;
			            _this.num = 59;
			          }
			        }, 1000);
			      } else {
			        _this.toast(res.data);
			      }
			    });
			  }
			},
			submit(){
				if(!this.mobile){
					this.toast('请输入手机号')
				}else if(!this.code){
					this.toast('请输入验证码')
				}else if(!this.pass1){
					this.toast('请输入登录密码')
				}else if(!this.pass2){
					this.toast('请确认登录密码')
				}else if(this.pass1 != this.pass2){
					this.toast('登录密码输入不一致')
				}else if(!this.safe1){
					this.toast('请输入安全密码')
				}else if(!this.safe2){
					this.toast('请确认安全密码')
				}else if(this.safe1 != this.safe2){
					this.toast('安全密码输入不一致')
				}else if(!this.pcode){
					this.toast('请输入邀请码')
				}else{
					this.regist()
				}
			},
			regist(){
				let _this = this;
				let params = {
					password:this.pass1,
					mobile:this.mobile,
					code:this.code,
					pcode:this.pcode,
					paypwd:this.safe1
				}
				this.$req('auth/register',params,(res)=>{
					if(res.code==1){
						_this.toast('注册成功');
						setTimeout(()=>{
							_this.uOpenWin('./login')
						},500)
					}else{
						_this.toast(res.data)
					}
				})
			},
		}
	}
</script>

<style>

</style>
